
# Imports
import time

# Object representing a physical host (node)
class PM:

	# Constructor 
	def __init__(self):
	
		# Set up network vars
		self.IP = ""
		
		# Set up state vars
		self.lastEnumerated = None
		
		# Set up VM vars
		self.VMs = []
	
	# Converts lastEnumerated timestamp to a string
	def GetLastEnumeratedAsString(self):
		
		return time.strftime("%Y-%m-%d %H:%M:%S", self.lastEnumerated)
	
	# Determines if this PM needs to be enumerated
	def NeedsEnumerating(self, freq):
		
		# Get latest snapshot timestamp and convert to a time
		latestTimestamp = self.lastEnumerated
		
		# If we didn't get a timestamp, return true
		if latestTimestamp == None:
			return True
		
		# Calculate the difference
		diffTime = int(time.mktime(time.localtime()) - time.mktime(latestTimestamp))
		
		# Check and see if we should snapshot
		if diffTime >= freq:
			return True
		else:
			return False